package com.binvshe.binvshe.mine.follow;

import android.app.Activity;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;

import com.binvshe.binvshe.R;
import com.binvshe.binvshe.account.utils.FragmentUtils;
import com.binvshe.binvshe.mine.follow.fragment.FollowClubFragment;
import com.binvshe.binvshe.mine.follow.fragment.FollowPersonFragment;
import com.pachong.android.baseuicomponent.activity.BaseActivity;

import butterknife.Bind;
import butterknife.OnClick;

public class MyFollowActivity extends BaseActivity {

    @Bind(R.id.mRbtnFollowPerson)
    RadioButton mRbtnFollowPerson;
    @Bind(R.id.mRbtnFollowClub)
    RadioButton mRbtnFollowClub;

    FollowPersonFragment mFollowPersonFragment = FollowPersonFragment.newInstance();
    FollowClubFragment mFollowClubFragment = FollowClubFragment.newInstance();

    public static void start(Activity activity) {
        Intent starter = new Intent(activity, MyFollowActivity.class);
        activity.startActivity(starter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initToolBar();
        initView();

    }

    private void initView() {
        mRbtnFollowPerson.setChecked(true);
    }

    private void initToolBar() {
        getCustomToolbar().setTitle("我关注的");
        enableBackButton();
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.act_my_follow, null);
        FragmentUtils.addFirstFragment(getSupportFragmentManager(), R.id.followContainer, mFollowPersonFragment);
        return view;
    }

    @OnClick({R.id.mRbtnFollowPerson, R.id.mRbtnFollowClub})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.mRbtnFollowPerson:
                FragmentUtils.replaceFragmentNoAnimation(getSupportFragmentManager(), R.id.followContainer, mFollowPersonFragment);
                break;
            case R.id.mRbtnFollowClub:
                FragmentUtils.replaceFragmentNoAnimation(getSupportFragmentManager(), R.id.followContainer, mFollowClubFragment);
                break;
        }
    }
}
